<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id' => 'user-form',
    'enableClientValidation' => true,
    'htmlOptions' => array(
        'enctype' => 'multipart/form-data',
    ),
    'type' => 'horizontal',
        ));

echo $form->errorSummary($model);
echo $form->errorSummary($profile);
?>
<ul class="nav nav-tabs">
    <li class="active"><a href="#main-info" data-toggle="tab">Main info</a></li>
    <li><a href="#profile" data-toggle="tab">Profile</a></li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="main-info">
        <?php if ($create): ?>

            <?php echo $form->textFieldRow($model, 'admin_login') ?>

            <?php echo $form->error($model, 'admin_login') ?>

        <?php else: ?>

            <div class="control-group">
                <label class="control-label">Login name</label>
                <div class="controls"><h3><?php echo $model->admin_login; ?></h3></div>
            </div>

        <?php endif; ?>

        <div class="control-group">
            <label class="control-label">Password (*)</label>
            <div class="controls">
                <?php echo $form->passwordfield($model, 'admin_password') ?>
                <?php echo $form->error($model, 'admin_password') ?>
                <p class="help-block">Empty to keep current</p>
            </div>
        </div>

        <div class="control-group">
            <label class="control-label">Repeat Password (*)</label>
            <div class="controls">
                <?php echo $form->passwordfield($model, 'repassword') ?>
            </div>
        </div>

        <?php //echo $form->textFieldRow($model, 'admin_nicename') ?>

        <?php echo $form->textFieldRow($model, 'admin_email') ?>

        <?php
        $role = user()->getModel();
        if ($role->admin_role == Admin::SUPER_ADMIN):
            ?>

            <?php echo $form->dropDownListRow($model, 'admin_role', Admin::getRoles()) ?>

            <?php echo $form->dropDownListRow($model, 'admin_status', Admin::getStatus()) ?>

        <?php endif; ?>
        <div class="control-group">
            <label class="control-label">Avatar</label>
            <div class="controls">
                <img src="<?php echo $model->getAvatarUrl() ?>" title="" />
                <br/>
                <?php echo CHtml::fileField('avatar') ?>
            </div>
        </div>
    </div>
    <div class="tab-pane" id="profile">
        <?php echo $form->textFieldRow($profile, 'firstname') ?>
        <?php echo $form->textFieldRow($profile, 'lastname') ?>
        <?php
        echo $form->datepickerRow($profile, 'birthdate', array(
            'prepend' => '<i class="icon-calendar"></i>',
            'options' => array(
                'format' => 'dd-mm-yyyy',
                'weekStart' => 1,
                'showButtonPanel' => true,
                'showAnim' => 'fold',)));
        ?>
        <?php echo $form->textAreaRow($profile, 'address') ?>
        <?php echo $form->textFieldRow($profile, 'phone') ?>
        <?php echo $form->textFieldRow($profile, 'profile_url') ?>
    </div>
</div>


<div class="form-actions">
    <input type="submit" class="btn btn-primary" value="Save" />
</div>

<?php $this->endWidget(); ?>